//////////////////////////////////////////////////////////////////////////

#ifndef _SOUNDS_H_
#include "sounds.h"
#endif

#include <SDL_mixer.h>
//////////////////////////////////////////////////////////////////////////


GUI_Sounds::GUI_Sounds(const std::string& _resourcesFolder):
    m_SoundsSubfolder("\\Music\\")
{
    m_ResourcesFolder = _resourcesFolder;

    ReloadSound(Shoot, "shoot.wav");
    ReloadSound(Click, "click.wav");
    ReloadSound(Hover, "hover.wav");
    ReloadMusic(Intro, "intro.ogg");
    ReloadMusic(Menu, "menu.ogg");
    ReloadMusic(Game, "game.ogg");
}


//////////////////////////////////////////////////////////////////////////


GUI_Sounds::~GUI_Sounds()
{
    for (int i = 0; i< SoundCount; ++i)
        Mix_FreeChunk(m_Sounds[i]);
    for (int i = 0; i< MusicCount; ++i)
        Mix_FreeMusic(m_Musics[i]);
}


//////////////////////////////////////////////////////////////////////////


void GUI_Sounds::ReloadMusic(GUI_Sounds::Music _music, const std::string& _fileName)
{
    m_Musics[_music] = Mix_LoadMUS((m_ResourcesFolder + m_SoundsSubfolder + _fileName).c_str());
}


//////////////////////////////////////////////////////////////////////////


void GUI_Sounds::ReloadSound(GUI_Sounds::Sound _sound, const std::string& _fileName)
{
    m_Sounds[_sound] = Mix_LoadWAV((m_ResourcesFolder + m_SoundsSubfolder + _fileName).c_str());
}


//////////////////////////////////////////////////////////////////////////


Mix_Chunk *GUI_Sounds::GetSound(GUI_Sounds::Sound _soundName)
{
    return m_Sounds[_soundName];
}


//////////////////////////////////////////////////////////////////////////


Mix_Music *GUI_Sounds::GetMusic(GUI_Sounds::Music _musicName)
{
    return m_Musics[_musicName];
}


//////////////////////////////////////////////////////////////////////////
